<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>登录 - 考勤管理系统</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        
        body {
            font-family: "Microsoft YaHei", Arial, sans-serif;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            min-height: 100vh;
            display: flex;
            justify-content: center;
            align-items: center;
            padding: 20px;
        }
        
        .login-container {
            background: white;
            border-radius: 20px;
            box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
            padding: 50px;
            width: 100%;
            max-width: 400px;
        }
        
        h1 {
            color: #667eea;
            text-align: center;
            margin-bottom: 10px;
            font-size: 32px;
        }
        
        .subtitle {
            text-align: center;
            color: #666;
            margin-bottom: 40px;
            font-size: 14px;
        }
        
        .form-group {
            margin-bottom: 25px;
        }
        
        .form-group label {
            display: block;
            margin-bottom: 10px;
            color: #333;
            font-weight: bold;
        }
        
        .form-group input {
            width: 100%;
            padding: 12px 15px;
            border: 2px solid #ddd;
            border-radius: 10px;
            font-size: 16px;
            transition: border-color 0.3s;
        }
        
        .form-group input:focus {
            outline: none;
            border-color: #667eea;
        }
        
        .login-btn {
            width: 100%;
            padding: 15px;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            border: none;
            border-radius: 10px;
            font-size: 18px;
            font-weight: bold;
            cursor: pointer;
            transition: transform 0.3s, box-shadow 0.3s;
        }
        
        .login-btn:hover {
            transform: translateY(-2px);
            box-shadow: 0 10px 25px rgba(102, 126, 234, 0.4);
        }
        
        .quick-login {
            margin-top: 20px;
            text-align: center;
        }
        
        .quick-login p {
            color: #666;
            font-size: 14px;
            margin-bottom: 10px;
        }
        
        .quick-login button {
            margin: 0 5px;
            padding: 8px 15px;
            background: #f8f9fa;
            border: 1px solid #ddd;
            border-radius: 5px;
            cursor: pointer;
            transition: all 0.3s;
        }
        
        .quick-login button:hover {
            background: #e9ecef;
            border-color: #667eea;
            color: #667eea;
        }
        
        .message {
            padding: 12px;
            border-radius: 8px;
            margin-bottom: 20px;
            text-align: center;
            display: none;
        }
        
        .message.error {
            background: #f8d7da;
            border: 1px solid #f5c6cb;
            color: #721c24;
            display: block;
        }
        
        .info-box {
            background: #e7f3ff;
            padding: 15px;
            border-radius: 10px;
            margin-top: 30px;
            font-size: 13px;
            color: #666;
        }
        
        .info-box strong {
            color: #333;
        }
    </style>
</head>
<body>
    <div class="login-container">
        <h1>🔐 登录</h1>
        <p class="subtitle">考勤管理系统 - Attendance Management System</p>
        
        <div id="message" class="message"></div>
        
        <form id="loginForm">
            <div class="form-group">
                <label for="username">用户名</label>
                <input type="text" id="username" placeholder="请输入用户名" required autocomplete="username">
            </div>
            <div class="form-group">
                <label for="password">密码（可选）</label>
                <input type="password" id="password" placeholder="本地演示无需密码" autocomplete="current-password">
            </div>
            <button type="submit" class="login-btn">登录</button>
        </form>
        
        <div class="quick-login">
            <p>快速登录（演示用）：</p>
            <button onclick="quickLogin('管理员')">管理员</button>
        </div>
        
        <div class="info-box">
            <strong>💡 提示：</strong><br>
            这是课程演示系统，采用本地会话存储。<br>
            输入任意用户名即可登录，无需密码验证。<br>
            会话信息仅保存在浏览器中。
        </div>
    </div>
    
    <script>
        // 检查是否已登录
        const currentUser = sessionStorage.getItem('currentUser');
        if (currentUser) {
            // 已登录，跳转到首页
            window.location.href = 'index.html';
        }
        
        // 登录表单提交
        document.getElementById('loginForm').addEventListener('submit', (e) => {
            e.preventDefault();
            
            const username = document.getElementById('username').value.trim();
            
            if (!username) {
                showMessage('请输入用户名');
                return;
            }
            
            // 保存到会话
            sessionStorage.setItem('currentUser', username);
            sessionStorage.setItem('loginTime', new Date().toISOString());
            
            // 跳转到首页
            window.location.href = 'index.html';
        });
        
        // 快速登录
        function quickLogin(username) {
            sessionStorage.setItem('currentUser', username);
            sessionStorage.setItem('loginTime', new Date().toISOString());
            window.location.href = 'index.html';
        }
        
        // 显示错误消息
        function showMessage(text) {
            const messageDiv = document.getElementById('message');
            messageDiv.textContent = text;
            messageDiv.className = 'message error';
            
            setTimeout(() => {
                messageDiv.className = 'message';
            }, 3000);
        }
    </script>
</body>
</html>

